#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int arr[5000001];
  for(int i=0;i<n;i++)scanf("%d",&arr[i]);
  nth_element(arr,arr+k,arr+n);
  printf("%d",arr[k]);
}